Add prompt-gateway: MCP-based task contract compiler and agent router#3
Open
DataDanAi wants to merge 4 commits intoRangizingo:mainfrom
Open
Add prompt-gateway: MCP-based task contract compiler and agent router#3DataDanAi wants to merge 4 commits intoRangizingo:mainfrom
DataDanAi wants to merge 4 commits intoRangizingo:mainfrom
Conversation
Implements a full prompt compilation pipeline that converts raw human input into structured task contracts, with MCP as the backbone for cross-surface interoperability (CLI, Cursor/IDE, desktop, local agents). Architecture: - Compiler: classifier, constraint extractor, context selector, contract builder - Policy engine: risk assessment, approval gates, tool scope guards - Runtime router: routes tasks to optimal execution surface - Validator: checks execution results against contract criteria - Storage: SQLite for runs, approvals, memory, policies, structured logs - MCP server: exposes all gateway capabilities as MCP tools/resources/prompts - HTTP server: REST endpoints (compile, execute, approve, validate, runs) - Input adapters: CLI, Cursor, desktop, local-agent - CLI entry point: `agent "fix the auth race and keep changes minimal"` https://claude.ai/code/session_01WvBZW9gNfJSXGnCF6UGakJ
- esbuild bundles CLI and daemon into single .mjs files (149K + 1.9M) - setup.sh: one-command install (npm install + build + PATH shims) - `agent "your prompt"` CLI command via bin shim - `prompt-gateway --mcp-config` prints Cursor/Claude/Claude Code config - `prompt-gateway --http` starts REST daemon on port 4840 - `prompt-gateway --mcp` starts MCP stdio server https://claude.ai/code/session_01WvBZW9gNfJSXGnCF6UGakJ
setup.sh and setup.ps1 now automatically: - Build the bundles - Create CLI shims (agent, prompt-gateway) - Auto-detect and configure Cursor, Claude Desktop, Claude Code, VS Code, and Windsurf MCP configs (merges without clobbering) - Add bin/ to PATH (bashrc/zshrc on Linux, user PATH on Windows) One command to install: `bash setup.sh` or `.\setup.ps1` https://claude.ai/code/session_01WvBZW9gNfJSXGnCF6UGakJ
Windows (setup.ps1 + setup.bat): - setup.bat for double-click install (bypasses execution policy) - Forward-slash paths in JSON configs (fixes backslash escaping) - PowerShell shims alongside .cmd shims - Graceful error handling for unparseable config files - JetBrains IDE auto-detection and config - Quick self-test after build - Pause-on-error when launched via double-click Linux (setup.sh): - Fix stdout leaking from node merge scripts - Add Windsurf and JetBrains auto-detection - Add quick self-test after build https://claude.ai/code/session_01WvBZW9gNfJSXGnCF6UGakJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces prompt-gateway, a new system that compiles raw human intent into structured task contracts and routes them to appropriate execution surfaces. It provides a unified interface for multiple clients (Cursor, CLI, desktop, local agents, APIs) through both MCP (Model Context Protocol) and HTTP servers.
Key Changes
Core Architecture
src/types.ts): Canonical schema for representing compiled tasks with intent, constraints, risk assessment, execution mode, and validation criteriasrc/compiler/): Multi-stage compilation from raw input to structured contracts:Server Implementations
src/mcp/server.ts): Exposes gateway as MCP tools for Cursor, Claude, and other MCP-compatible clients with operations: compile, evaluate, route, approve, validate, get-runsrc/server/http.ts): REST API endpoints for compile, execute, approve, and run managementsrc/bin/agent.ts): Command-line entry point with human-readable and JSON output modesPolicy & Routing
src/policy/engine.ts): Rule-based evaluation of compiled contracts (approval requirements, surface permissions, risk gates)src/router/index.ts): Intelligent routing logic that maps task types to execution surfaces (Cursor for code editing, CLI for shell work, desktop for design specs, etc.)Storage & Validation
src/storage/db.ts): Persistent run tracking, approvals, memory, policies, and logs with WAL modesrc/validator/index.ts): Post-execution validation against contract criteria (compilation checks, test passes, exit codes, deployment health)Input Adapters
src/adapters/cli.ts): Captures working directory, git state, environmentsrc/adapters/cursor.ts): IDE-specific metadata extractionsrc/adapters/desktop.ts): UI surface transport layersrc/adapters/local-agent.ts): Agent-to-gateway communicationNotable Implementation Details
Configuration
.prompt-gateway/gateway.db--httpand--mcpflags to run servers independentlyhttps://claude.ai/code/session_01WvBZW9gNfJSXGnCF6UGakJ